cmake_minimum_required(VERSION 3.15)

project(kkgui C CXX)

include_directories(include src/components/include)

# 生成 compile_commands.json，不支持msvc
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(MSVC)
  add_definitions(-DUNICODE)
  add_definitions(-D_WIN32_WINNT=0x600)
  add_compile_options("/source-charset:utf-8")
  add_definitions(-DNOMINMAX) # disable msvc max/min
  set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS True )
endif()

message(STATUS "Begain build library ...")
set(LIB_SRC 
  "./src/utils/comm.cpp"
  "./src/window/win32.cpp"
  "./src/render/cairo.cpp"
  "./src/components/container.cpp"
)

add_library(${PROJECT_NAME} ${LIB_SRC})
if(MSVC)
  target_link_libraries(${PROJECT_NAME} kernel32 user32 gdi32 shell32 advapi32 comdlg32 gdiplus Imm32)
endif ()

message(STATUS "Begain build exe ...")

set(SAMPLE_HELLO_SRC
  "./samples/hello/main.cpp"
)
add_executable(sample_hello ${SAMPLE_HELLO_SRC} logo.rc)
target_link_libraries(sample_hello ${PROJECT_NAME})

message(STATUS "Build finished.")

# copy
message(STATUS "Copy resource...")
add_custom_command(TARGET sample_hello POST_BUILD   
  COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${PROJECT_SOURCE_DIR}/logo.ico" $<TARGET_FILE_DIR:sample_hello>
)


# D2D1 win32 demo
include(./samples/D2D1/build.cmake)